Skip to content

impl(bigtable): update stub_factory and connection creation functions for dynamic pool#16052

Merged
scotthart merged 3 commits intogoogleapis:mainfrom
scotthart:bigtable_dynamic_stub_factory
Mar 24, 2026
Merged

impl(bigtable): update stub_factory and connection creation functions for dynamic pool#16052
scotthart merged 3 commits intogoogleapis:mainfrom
scotthart:bigtable_dynamic_stub_factory

Conversation

@scotthart
Copy link
Copy Markdown
Member

Adds new functions and branch to create stubs using the DynamicChannelPool.

@scotthart scotthart requested a review from a team as a code owner March 23, 2026 21:25
@product-auto-label product-auto-label bot added the api: bigtable Issues related to the Bigtable API. label Mar 23, 2026
@gemini-code-assist
Copy link
Copy Markdown

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request enhances the Bigtable client library by introducing support for dynamic channel pooling and instance affinity. This allows the client to maintain separate, optimized connections for different Bigtable instances, potentially improving performance and resource utilization by priming connections and using a more intelligent channel selection strategy (random two least used) when instance affinity is enabled.

Highlights

  • Dynamic Channel Pooling: Introduced an experimental::InstanceChannelAffinityOption that, when set, enables the creation of a dynamic channel pool for Bigtable connections, allowing for instance-specific channel affinity and priming.
  • Conditional Stub Creation: Modified MakeDataConnection to conditionally create DataConnectionImpl using a StubManager that leverages the new dynamic channel pool if the InstanceChannelAffinityOption is configured, otherwise falling back to the existing round-robin stub creation.
  • New Stub Factory Functions: Added new stub factory functions, including CreateBigtableStubRandomTwoLeastUsed and overloaded CreateBigtableStub and CreateBigtableAffinityStubs, to support the creation and management of stubs within the dynamic channel pool, including PingAndWarm priming.
  • Code Refactoring: Refactored common stub decorators into a new helper function ApplyCommonDecorators to reduce code duplication and improve maintainability across different stub creation paths.
  • New Test Coverage: Added new test cases to data_connection_test.cc and bigtable_stub_factory_test.cc to verify the functionality of the InstanceChannelAffinityOption, the RandomTwoLeastUsed channel selection strategy, and the CreateBigtableAffinityStubs function.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces support for a dynamic channel pool with instance affinity, a significant enhancement for managing Bigtable connections. The changes are well-structured, introducing a new experimental option InstanceChannelAffinityOption to control the feature. The implementation correctly branches based on this option in MakeDataConnection, preserving the existing behavior for users who do not opt-in. The introduction of StubManager provides a clean abstraction for managing stubs, whether it's a single shared stub or multiple affinity-based stubs. The new BigtableRandomTwoLeastUsed decorator and DynamicChannelPool implement the core logic for the new connection management strategy. The code is well-refactored, for example, by extracting common decorator logic into ApplyCommonDecorators, which improves maintainability. The changes are also accompanied by thorough tests, covering both the new logic and ensuring existing functionality is not broken. Overall, this is a high-quality contribution that thoughtfully adds a powerful new feature.

@codecov
Copy link
Copy Markdown

codecov bot commented Mar 23, 2026

Codecov Report

❌ Patch coverage is 96.70330% with 6 lines in your changes missing coverage. Please review.
✅ Project coverage is 92.69%. Comparing base (eb60077) to head (c5cefff).
⚠️ Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
...e/cloud/bigtable/internal/bigtable_stub_factory.cc 93.10% 6 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff            @@
##             main   #16052    +/-   ##
========================================
  Coverage   92.68%   92.69%            
========================================
  Files        2342     2342            
  Lines      216379   216537   +158     
========================================
+ Hits       200554   200709   +155     
- Misses      15825    15828     +3     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Copy Markdown
Collaborator

@diegomarquezp diegomarquezp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM overall, just a minor comment

Comment thread google/cloud/bigtable/internal/bigtable_stub_factory.h
@scotthart scotthart enabled auto-merge (squash) March 24, 2026 17:13
@scotthart scotthart closed this Mar 24, 2026
auto-merge was automatically disabled March 24, 2026 18:22

Pull request was closed

@scotthart scotthart reopened this Mar 24, 2026
@scotthart scotthart merged commit 6e24ab6 into googleapis:main Mar 24, 2026
59 of 67 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

api: bigtable Issues related to the Bigtable API.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants